/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entidade.controller.JSF.util;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;

/**
 *
 * @author victorinox
 */
public class UtilController {

    public UtilController() {
    }

    public SelectItem[] getArrayMeses() {
        SelectItem[] itens = new SelectItem[12];
        for (int i = 1; i < 13; i++) {
            String val = "";
            if (i < 10) {
                val = "0" + String.valueOf(i);
            } else {
                val = String.valueOf(i);
            }
            itens[i - 1] = new SelectItem(String.valueOf(i), val);
        }
        return itens;
    }

    public SelectItem[] getArrayDias() {
        SelectItem[] itens = new SelectItem[31];
        for (int i = 1; i < 32; i++) {
            String val = "";
            if (i < 10) {
                val = "0" + String.valueOf(i);
            } else {
                val = String.valueOf(i);
            }
            itens[i - 1] = new SelectItem(String.valueOf(i), val);
        }
        return itens;
    }

    public SelectItem[] getArrayAnos() {
        int minYear = 1920;
        int year = Calendar.getInstance().get(Calendar.YEAR);
        SelectItem[] itens = new SelectItem[year - minYear + 1];
        for (int i = 0; minYear + i <= year; i++) {
            int y = minYear + i;
            itens[i] = new SelectItem(String.valueOf(y), String.valueOf(y));
        }
        return itens;
    }

    public SelectItem[] getArrayAnosMaisDez() {
        int minYear = 1920;
        int year = Calendar.getInstance().get(Calendar.YEAR) + 10;
        SelectItem[] itens = new SelectItem[year - minYear + 1];
        for (int i = 0; minYear + i <= year; i++) {
            int y = minYear + i;
            itens[i] = new SelectItem(String.valueOf(y), String.valueOf(y));
        }
        return itens;
    }

     public SelectItem[] getArray_0_to_10() {
        List<SelectItem> arr = new ArrayList<SelectItem>();
        for (int i = 0; i < 11; i++) {
            arr.add(new SelectItem(new Integer(i), String.valueOf(i)));
        }
        return arr.toArray(new SelectItem[arr.size()]);
    }

     public SelectItem[] getArray_1_to_50() {
        List<SelectItem> arr = new ArrayList<SelectItem>();
        for (int i = 1; i < 51; i++) {
            arr.add(new SelectItem(new Integer(i), String.valueOf(i)));
        }
        return arr.toArray(new SelectItem[arr.size()]);
    }

     public Float getZeroFloat(){
         return new Float(0.0);
     }

}
